package com.china08.yxyapi.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager;
import org.springframework.cache.ehcache.EhCacheCacheManager;
import org.springframework.cache.ehcache.EhCacheManagerFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

/**
 * Cache Config: EhCache
 * 
 * @author Ertao.Fang
 *
 */
@Profile("oth")
// @Profile(value = { "dev", "tes", "pro" })
@Configuration
public class CacheConfigForEhCache extends CacheConfig {

    public static final Logger LOGGER = LoggerFactory.getLogger(CacheConfigForEhCache.class);

    @Bean
    CacheManager cacheManager(EhCacheManagerFactoryBean bean) {
        EhCacheCacheManager manager = new EhCacheCacheManager(bean.getObject());
        manager.getCacheManager().addCache(DCN);
        // manager.getCacheManager().addCache(YxCacheUtil.CACHE_USER_OBJ);
        // manager.getCacheManager().addCache(YxCacheUtil.CACHE_USER_OBJ_LIST);
        return manager;
    }

    @Bean
    EhCacheManagerFactoryBean ehCacheManagerFactoryBean() {
        EhCacheManagerFactoryBean bean = new EhCacheManagerFactoryBean();
        bean.setShared(true);
        return bean;
    }

}
